Ignore new mystery packets in StreetPilot 2.70. Add Garmulator. Improve
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 6 Jun 2004 21:35:28 +0000 (21:35 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 6 Jun 2004 21:35:28 +0000 (21:35 +0000)
serial debug output.

gpsbabel/Makefile
gpsbabel/jeeps/gpsapp.c
gpsbabel/jeeps/gpssend.c
gpsbabel/jeeps/gpsserial.c

index 897d3fbec646ca01bf89fa49e97a3353ffba269a..3608fbcf98974b14a0cb4db73c3358442d4acd03 100644 (file)
@@ -78,10 +78,10 @@ dep:
        (echo -n "internal_styles.c: mkstyle.sh " ; echo style/*.style ; /bin/echo -e '\t./mkstyle.sh > internal_styles.c || (rm -f internal_styles.c ; exit 1)' ) >> /tmp/dep
        echo Edit Makefile and bring in /tmp/dep
 
-#VERSIONU=1_2_3_beta04272004
-#VERSIOND=1.2.3_beta04272004
-VERSIONU=1_2_3
-VERSIOND=1.2.3
+VERSIONU=1_2_4_betajonnmiki
+VERSIOND=1.2.4_betajonnmiki
+#VERSIONU=1_2_3
+#VERSIOND=1.2.3
 
 release:
        cvs commit
index 0649a8e4af32b91ff064fa6164f3609198c7818c..29e6d6d3d5155ac54116b875325ceb9f8116900f 100644 (file)
@@ -208,12 +208,21 @@ static int32 GPS_A000(const char *port)
     }
     else
     {
-       (void) GPS_Packet_Read(fd, &rec);
-       GPS_Send_Ack(fd, &tra, &rec);
-       GPS_A001(rec);
+        int maxct = 3;
+       while (maxct--) {
+               char pb[256];
+               (void) GPS_Packet_Read(fd, &rec);
+               GPS_Send_Ack(fd, &tra, &rec);
+               if (rec->type == 0xfd) {
+                       GPS_A001(rec);
+                       break;
+               }
+               snprintf(pb, sizeof(pb), "Ignoring unknown packet 0x%x.", 
+                               rec->type);
+               GPS_Warning(pb);
+       }
     }
 
-
     /* Make sure PVT is off as some GPS' have it on by default */
     if(gps_pvt_transfer != -1)
        GPS_A800_Off(port,&fd);
@@ -5580,4 +5589,52 @@ void GPS_D800_Get(GPS_PPacket packet, GPS_PPvt_Data *pvt)
 }
 
 
+/* 
+ *  It's unfortunate that these aren't constant and therefore switchable,
+ *  but they really are runtime variable.  Sigh.
+ */
 
+const char *
+Get_Pkt_Type(unsigned char p)
+{
+#define LT LINK_ID[gps_link_type]
+       if (p == LT.Pid_Ack_Byte)
+               return "ACK";
+       if (p == LT.Pid_Command_Data)
+               return "CMDDAT";
+       if (p == LT.Pid_Xfer_Cmplt)
+               return "XFRCMP";
+       if (p == LT.Pid_Date_Time_Data)
+               return "DATTIM";
+       if (p == LT.Pid_Position_Data)
+               return "POS";
+       if (p == LT.Pid_Prx_Wpt_Data)
+               return "WPT";
+       if (p == LT.Pid_Nak_Byte)
+               return "NAK";
+       if (p == LT.Pid_Records)
+               return "RECORD";
+       if (p == LT.Pid_Rte_Hdr)
+               return "RTEHDR";
+       if (p == LT.Pid_Rte_Wpt_Data)
+               return "RTEWPT";
+       if (p == LT.Pid_Almanac_Data)
+               return "RALMAN";
+       if (p == LT.Pid_Trk_Data)
+               return "TRKDAT";
+       if (p == LT.Pid_Wpt_Data)
+               return "WPTDAT";
+       if (p == LT.Pid_Pvt_Data)
+               return "PVTDAT";
+       if (p == LT.Pid_Rte_Link_Data)
+               return "LNKDAT";
+       if (p == LT.Pid_Trk_Hdr)
+               return "TRKHDR";
+       if (p == LT.Pid_Protocol_Array)
+               return "PRTARR";
+       if (p == LT.Pid_Product_Rqst)
+               return "PRDREQ";
+       if (p == LT.Pid_Product_Data)
+               return "PRDDAT";
+       return "UNKNOWN";
+}
index 767d921e6523e3dd16316016ea92ade0181d559a..bad9ccfc1e85d5343a320f6acb6b36592c5c615a 100644 (file)
@@ -125,7 +125,7 @@ int32 GPS_Write_Packet(int32 fd, GPS_PPacket packet)
 {
     size_t ret;
 
-    GPS_Diag("\nTx Data:");
+    GPS_Diag("Tx Data:");
     Diag(&packet->dle, 3);    
     if((ret=GPS_Serial_Write(fd,(const void *) &packet->dle,(size_t)3)) == -1)
     {
@@ -158,6 +158,7 @@ int32 GPS_Write_Packet(int32 fd, GPS_PPacket packet)
     GPS_Diag(": ");
     DiagS(packet->data, packet->bytes);
     DiagS(&packet->chk, 3);
+    GPS_Diag("(%-8s)\n", Get_Pkt_Type(packet->type));
 
     if((ret=GPS_Serial_Write(fd,(const void *)&packet->chk,(size_t)3)) == -1)
     {
index 5b6d02ebc408672ba135601da03044c38452e629..9f967edda7e21eca31c63aebee3e2d9427696dd1 100644 (file)
 #include <stdio.h>
 #include <time.h>
 
+#if 0
+#define GARMULATOR 1
+char *rxdata[] = {
+       "10 06 02 fe 00 fa 10 03",
+       "10 ff 7d 97 00 0e 01 53 74 72 65 65 74 50 69 6c 6f 74 20 33 20 53 6f 66 74 77 61 72 65 20 56 65 72 73 69 6f 6e 20 32 2e 37 30 00 56 45 52 42 4d 41 50 20 41 6d 65 72 69 63 61 73 20 41 75 74 6f 72 6f 75 74 65 20 31 2e 30 30 00 56 45 52 41 55 44 20 45 6e 67 6c 69 73 68 20 33 2e 30 31 00 56 45 52 53 50 4c 53 43 52 4e 20 53 70 6c 61 73 68 20 53 63 72 65 65 6e 20 4d 69 73 73 69 6e 67 00 f1 10 03",
+       "10 f8 0e 56 45 52 53 4d 41 50 31 20 4e 6f 6e 65 00 fb 10 03",
+
+       /* Guessing from here down */
+       /* "10 06 02 fe 00 fa 10 03", /* Ack the unknown packet */
+       "10 fd 24 50 00 00 4c 01 00 41 0a 00 41 64 00 44 6d 00 41 c9 00 44 ca 00 44 6d 00 44 d2 00 41 2d 01 44 36 01 44 2d 01 66 10 03", /* PTR Array */
+       "10 06 02 0a 00 ee 10 03", /* Ack */
+       "10 0e 08 06 04 d4 07 00 17 3a 30 84 10 03", /* DATTIME */
+       "10 06 02 0a 00 ee 10 03", /* Ack */
+       "10 1b 02 09 00 da 10 03", /* RECORD */
+       "10 06 02 0a 00 ee 10 03", /* Ack */
+       "10 23 5f 01 00 ff 70 3f 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 a6 1b aa 19 6e 78 5c c2 00 00 00 00 51 59 04 69 00 00 00 00 00 00 00 00 ff ff ff ff 47 43 31 41 33 37 00 54 68 65 20 54 72 6f 6c 6c 20 62 79 20 61 31 38 32 70 69 6c 6f 74 20 26 20 46 61 6d 69 6c 79 00 00 00 00 00 59 10 03"
+       "10 0c 02 07 00 eb 10 03" /* XFERCMP */
+};
+#endif
 /* 
  * termio on Cygwin is apparently broken, so we revert to Windows serial.
  */
@@ -275,7 +294,29 @@ int32 GPS_Serial_Open(int32 *fd, const char *port)
 
 int32 GPS_Serial_Read(int32 handle, void *ibuf, int size)
 {
-               return read(handle, ibuf, size);
+#if GARMULATOR
+       static int l;
+       static char *rp;
+       char **rxp = &rxdata[l];
+       char *hex;
+       char *rx = *rxp;
+       char *ib = ibuf;
+
+       if (!rp) rp = rxdata[0];
+
+       /* Skip over nulls in our pasted strings */
+       if (*rp == 0) {
+               rp = rxdata[++l];
+       }
+
+       *ib = strtoul(rp, &rp, 16);
+       if (*rp) rp++;
+       fprintf(stderr, ".");
+       return 1;
+
+#else
+       return read(handle, ibuf, size);
+#endif
 }
 
 int32 GPS_Serial_Write(int32 handle, const void *obuf, int size)
@@ -345,13 +386,20 @@ int32 GPS_Serial_Chars_Ready(int32 fd)
 {
     fd_set rec;
     struct timeval t;
+#if GARMULATOR
+    static foo;
+    /* Return sporadic reads just to torment the rest of the code. */
+    if ((foo++ & 0xf) == 0)
+       return 1;
+    else
+       return 0;
+#endif
 
     FD_ZERO(&rec);
     FD_SET(fd,&rec);
 
     t.tv_sec  = 0;
     t.tv_usec = 0;
-
     (void) select(fd+1,&rec,NULL,NULL,&t);
     if(FD_ISSET(fd,&rec))
        return 1;